<?php defined('SYSPATH') or die('No direct script access.');

abstract class Controller_Widget_Base extends Controller
{
	protected $layout = null;
    protected $need_auth = false;
    protected $message = null;
    
    protected function is_need_auth()
    {
        return $this->need_auth;
    }
    
    protected function add_message($message)
    {
        $this->message = $message;   
    }
    
    public function before()
    {
        // TODO проверка по домену
        $shop_id = $this->request->param('shop_id');
        ORM::factory('shop', $shop_id)->set_as_current();
        
        $this->layout = ORM::factory('shop')->get_widget_layout();
    }
    
    public function print_no_reviews()
    {
        $this->layout = new View($this->layout);     
        $content = ORM::factory('shop')->get_widget_view('index/no_reviews_tpl');
        $this->layout->content = $content;
        $this->response->body($this->layout);
    }
	
	public function print_template($content)
	{
        $this->layout = new View($this->layout);

		$this->layout->content     = $content;
        $this->layout->message     = $this->message;
		
		$this->response->body($this->layout);
	}

}
